package com.authine.cloudpivot.ext.enums.order;

import com.authine.cloudpivot.ext.enums.order.transfer.MemberPurchaseOrderEnum;

/**
 * @author 张天赐
 */
public enum OrderGoodsStatusEnum {

    /**
     * 订单商品状态
     */
    UpcomingPayment(1,"未付款"),
    UpcomingConfirm(2,"未接单"),
    UpcomingDelivery(3,"未发货"),
    DoneDelivery(4,"已发货"),
    Done(5,"已完成"),
    Closed(6,"已关闭");
    public Integer id;
    public String des;

    OrderGoodsStatusEnum(Integer id,String des) {
        this.id = id;
        this.des = des;
    }

    public static OrderGoodsStatusEnum get(Integer code) {

        for (OrderGoodsStatusEnum c : OrderGoodsStatusEnum.values()) {
            if (c.id.toString().equals(code.toString())) {
                return c;
            }
        }
        return null;
    }

    public static OrderGoodsStatusEnum switchNew(Integer status, Integer vendorStatus) {
        if (status.equals(1) || status.equals(2)) {
            return OrderGoodsStatusEnum.UpcomingPayment;
        }
        if (vendorStatus.equals(2)) {
            return OrderGoodsStatusEnum.UpcomingConfirm;
        }
        if (status.equals(3) || status.equals(4)) {
            return OrderGoodsStatusEnum.UpcomingDelivery;
        }
        if (status.equals(5)) {
            return OrderGoodsStatusEnum.DoneDelivery;
        }
        if (status.equals(11)) {
            return OrderGoodsStatusEnum.Done;
        }
        if (status.equals(12)) {
            return OrderGoodsStatusEnum.Closed;
        }

        return null;
    }
}
